﻿<?php
	include '../inc/conn.php';
	session_start();
	extract($_POST);
	extract($_GET);
	unset($_POST,$_GET);
	if (isset($act) && isset($id))
	{
		if ($act == "del"){
			$db = new mysql();
			$db->delete('weekly_report', "id=".$id);
			$db->close();
			echo "<script>alert('数据删除成功!!!');window.location='admin_index.php?name=weekly';</script>";
		}
	}

	$sStatus="'NOP'";
	if(isset($isCrisis))	$sStatus.=",'Crisis'";
	if(isset($isCritical))	$sStatus.=",'Critical'";
	if(isset($isMinor))		$sStatus.=",'Minor'";
	if(isset($isTracking))	$sStatus.=",'Tracking'";
	if(isset($isClosed))	$sStatus.=",'Closed'";
	
	if(isset($isTracking) || isset($isMinor) || isset($isCritical) || isset($isCrisis)|| isset($isClosed))
	{
		$sStatus= "and (Status in ($sStatus) )";
	}else
		$sStatus=" ";
	
	//echo "				\n<!---- tett:$sStatus ---->\n";
	
	echo "<div class='container-fluid'>";
	if ($_SESSION['user'] != 1){  
		echo '<script>window.location="userinfo.php"</script>';
	} else {
		echo "<div class='panel panel-primary'>";
		echo "	<div class='panel-heading'>";
		echo "		<h3 class='panel-title'>管理面板>>周报汇总表</h3>\n";
		echo "	</div>\n";
		echo "	<div class='panel-body'>\n";
		echo "		<div>\n";
		echo "		<div class='well'>\n";
		echo "			<form class='form-inline' action='admin_index.php?name=weekly' method='post'>\n";	
		echo "				<div style='form-group'>\n";
		if (isset($search)){
			echo "	周报搜索：<input type='text' class='form-control' name='search' value='$search' ><button type='submit' class='btn btn-info'>搜索</button>&nbsp;&nbsp;";
?>	
		状态【&nbsp;		Crisis: <input type='checkbox' name='isCrisis' value='1' 		<? if(isset($isCrisis)) echo "checked='checked'"; ?> />
				&nbsp;&nbsp;Critical: <input type='checkbox' name='isCritical' value='1' 	<? if(isset($isCritical)) echo "checked='checked'"; ?> />
				&nbsp;&nbsp;Minor: <input type='checkbox' name='isMinor' value='1' 			<? if(isset($isMinor)) echo "checked='checked'"; ?> />
				&nbsp;&nbsp;Tracking: <input type='checkbox' name='isTracking' value='1' 	<? if(isset($isTracking)) echo "checked='checked'"; ?> />
				&nbsp;&nbsp;Closed: <input type='checkbox' name='isClosed' value='1' 		<? if(isset($isClosed)) echo "checked='checked'"; ?> />
		&nbsp;】
<?
		}else
			echo "				周报搜索：<input type='text' class='form-control' name='search'><button type='submit' class='btn btn-info'>搜索</button>&nbsp;&nbsp;
											状态【&nbsp;		Crisis: <input type='checkbox' name='isCrisis' value='1' />&nbsp;&nbsp;Critical: <input type='checkbox' name='isCritical' value='1' />
											&nbsp;&nbsp;Minor: <input type='checkbox' name='isMinor' value='1' />&nbsp;&nbsp;Tracking: <input type='checkbox' name='isTracking' value='1' />&nbsp;&nbsp;Closed: <input type='checkbox' name='isClosed' value='1'>&nbsp; 】";
		echo "				<div style='float:right'>操作：<a href='#' onclick=\"javascript:window.open('weekly_report.php?pagename=additem','周报', 'height=860, width=1000, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');\"><span class=\"glyphicon glyphicon-plus\"></span> 添加</a>";
		echo " | <a href='#' onclick=\"javascript:window.open('weekly_report.php?pagename=report','周报', 'toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');\"><b><span class=\"glyphicon glyphicon-new-window\"></span> 报告</b></a></div>\n";
		echo "				</div>\n";
		echo "			</form>\n";
		echo "		</div>\n";
		echo "			<table border=0 cellpadding=0 class='table table-striped'>\n";
		echo "			<tr class='success'><th>Item</th><th>Problem summary</th><th>What we did</th><th>What we can do?</th><th>Project</th><th>Owner</th><th>Status</th><th>Admin</th></tr>\n";
		$db = new mysql();
		if (isset($search))
		{
			//echo "\n<!-- select * from weekly_report where (Issues like '%$search%' or Project like '%$search%' or WeDid like '%$search%') $sStatus -->";
			$db->query("select * from weekly_report where `DEPT` ='".$_SESSION['dept']."' and (Issues like '%$search%' or Project like '%$search%' or WeDid like '%$search%') $sStatus");		
		}else
			$db->query("select * from weekly_report where `DEPT` ='".$_SESSION['dept']."' ORDER BY add_date DESC");
		$num = $db->db_num_rows();
		for($i=0; $i<$num; $i++){
			$row = $db->fetch_assoc();
			$item = $i + 1;
			echo "			<tr>";
			echo "<td>$item</td>";
			echo "<td><a href='#' rel='tooltip' title='查看详细' onclick=\"javascript:window.open('weekly_report.php?pagename=reviewitem&id=${row['ID']}', '查看', 'height=860, width=1000, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');\">".htmlspecialchars_decode($row['Issues'])."</a></td>";
			//echo "<td>".htmlspecialchars_decode($row['Risks'])."</td>";
			echo "<td>".htmlspecialchars_decode($row['WeDid'])."</td>";
			echo "<td>".htmlspecialchars_decode($row['WillDo'])."</td>";
			echo "<td>".htmlspecialchars_decode($row['Project'])."</td>";
			//echo "<td>".htmlspecialchars_decode($row['Trigger date'])."</td>";
			//echo "<td>".htmlspecialchars_decode($row['Issue date'])."</td>";
			echo "<td>".htmlspecialchars_decode($row['Owner'])."</td>";
			if($row['Status']=='Crisis')	echo "<td style='vertical-align: middle;text-align: center;background:#c00000'>C</td>";
			if($row['Status']=='Critical')	echo "<td style='vertical-align: middle;text-align: center;background:#ff0000'>R</td>";
			if($row['Status']=='Minor')		echo "<td style='vertical-align: middle;text-align: center;background:#ffff00'>Y</td>";
			if($row['Status']=='Tracking')	echo "<td style='vertical-align: middle;text-align: center;background:#e6b8b7'>T</td>";
			if($row['Status']=='Closed')	echo "<td style='vertical-align: middle;text-align: center;background:#888888'>Closed</td>";
			//echo "<td>".htmlspecialchars_decode($row['Remark'])."</td>";
			echo "<td><a href='#' rel='tooltip' title='修改' onclick=\"javascript:window.open('weekly_report.php?pagename=changeitem&id=${row['ID']}', '修改', 'height=860, width=1000, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');\"><span class=\"glyphicon glyphicon-edit\"></span></a>";
			if (isset($_SESSION['admin']))
				echo " | <a href=\"admin_weekly.php?id=".$row['ID']."&act=del\" rel='tooltip' title='删除问题点，当心哦~~~'><font color='red'><span class=\"glyphicon glyphicon-remove\"></span></font></a></td>";
			echo "</tr>\n";
		}

		echo "		</table>";
		echo "	</div>";
		echo "</div>";
		echo "</div>";
		echo "</div>";
}
//	include 'bottom.php';
	$db->close();
?>
